/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.spakehelpdesk.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author leehoanh
 */
@Entity
@Table(name = "Complaint", catalog = "HelpDesk", schema = "dbo")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Complaint.findByTechnicainIsNull", query = "SELECT c FROM Complaint c WHERE c.technicianID IS NULL"),
    @NamedQuery(name = "Complaint.findByPriorityIsNull", query = "SELECT c FROM Complaint c WHERE c.priorityID IS NULL"),
    @NamedQuery(name = "Complaint.findByCategory", query = "SELECT c FROM Category ca ,IN (ca.complaintList) c WHERE ca.categoryID = :categoryID"),
    @NamedQuery(name = "Complaint.sortWithCategory", query = "SELECT c FROM Category ca ,IN (ca.complaintList) c ORDER BY ca.categoryID DESC"),
    @NamedQuery(name = "Complaint.findByStatusAndDateLodg", query = "SELECT c FROM Status s ,IN (s.complaintList) c WHERE s.statusId = :statusId and c.dateLodge BETWEEN :dateLodge1 AND :dateLodge2"),
    @NamedQuery(name = "Complaint.findByStatus", query = "SELECT c FROM Status s ,IN (s.complaintList) c WHERE s.statusName = :statusName"),
    @NamedQuery(name = "Complaint.sortWithStatus", query = "SELECT c FROM Status s ,IN (s.complaintList) c ORDER BY s.statusName DESC"),
    @NamedQuery(name = "Complaint.findByPriority", query = "SELECT c FROM Priority p ,IN (p.complaintList) c WHERE p.priorityID = :priorityID"),
    @NamedQuery(name = "Complaint.sortWithPriority", query = "SELECT c FROM Priority p ,IN (p.complaintList) c ORDER BY p.priorityID DESC"),
    @NamedQuery(name = "Complaint.findCompOfAccount", query = "SELECT c FROM Account a ,IN (a.complaintList) c WHERE a.accountID = :accountID"),
    @NamedQuery(name = "Complaint.sortWithAccount", query = "SELECT c FROM Account a ,IN (a.complaintList) c ORDER BY a.accountID DESC"),
    @NamedQuery(name = "Complaint.findCompOfTechnicain", query = "SELECT c FROM Account a ,IN (a.complaintList1) c WHERE a.accountID = :accountID"),
    @NamedQuery(name = "Complaint.findByDateLodgBetween", query = "SELECT c FROM Complaint c WHERE c.dateLodge BETWEEN :dateLodge1 AND :dateLodge2"),
    @NamedQuery(name = "Complaint.sortWithDateLodg", query = "SELECT c FROM Complaint c ORDER BY c.dateLodge DESC"),
    @NamedQuery(name = "Complaint.findByActualTimeBetween", query = "SELECT c FROM Complaint c WHERE c.actualTime BETWEEN :actualTime1 AND :actualTime2"),
    @NamedQuery(name = "Complaint.findAll", query = "SELECT c FROM Complaint c"),
    @NamedQuery(name = "Complaint.findByDepartment", query = "SELECT c FROM Department d, IN(d.accountList) a,IN(a.complaintList) c WHERE d.departmentID = :departmentID "),
    @NamedQuery(name = "Complaint.sortWithDepartment", query = "SELECT c FROM Department d, IN(d.accountList) a,IN(a.complaintList) c ORDER BY d.departmentID DESC"),
    @NamedQuery(name = "Complaint.findByComplaintID", query = "SELECT c FROM Complaint c WHERE c.complaintID = :complaintID"),
    @NamedQuery(name = "Complaint.findByComplaintNo", query = "SELECT c FROM Complaint c WHERE c.complaintNo = :complaintNo"),
    @NamedQuery(name = "Complaint.findByActualTime", query = "SELECT c FROM Complaint c WHERE c.actualTime = :actualTime"),
    @NamedQuery(name = "Complaint.findByDateLodge", query = "SELECT c FROM Complaint c WHERE c.dateLodge = :dateLodge"),
    @NamedQuery(name = "Complaint.findByDateClose", query = "SELECT c FROM Complaint c WHERE c.dateClose = :dateClose"),
    @NamedQuery(name = "Complaint.findBySendTimes", query = "SELECT c FROM Complaint c WHERE c.sendTimes = :sendTimes")})
public class Complaint implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue
    @Basic(optional = false)
    @NotNull
    @Column(name = "ComplaintID", nullable = false)
    private Integer complaintID;
    @Size(max = 10)
    @Column(name = "ComplaintNo", length = 10)
    private String complaintNo;
    @Column(name = "ActualTime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date actualTime;
    @Column(name = "DateLodge")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateLodge;
    @Column(name = "DateClose")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateClose;
    @Lob
    @Size(max = 1073741823)
    @Column(name = "Note", length = 1073741823)
    private String note;
    @Column(name = "SendTimes")
    private Integer sendTimes;
    @Lob
    @Size(max = 1073741823)
    @Column(name = "Description", length = 1073741823)
    private String description;
    @JoinColumn(name = "Status", referencedColumnName = "StatusId")
    @ManyToOne
    private Status status;
    @JoinColumn(name = "PriorityID", referencedColumnName = "PriorityID")
    @ManyToOne
    private Priority priorityID;
    @JoinColumn(name = "CategoryID", referencedColumnName = "CategoryID")
    @ManyToOne
    private Category categoryID;
    @JoinColumn(name = "AccountID", referencedColumnName = "AccountID")
    @ManyToOne
    private Account accountID;
    @JoinColumn(name = "TechnicianID", referencedColumnName = "AccountID")
    @ManyToOne
    private Account technicianID;

    public Complaint() {
    }

    public Complaint(Integer complaintID) {
        this.complaintID = complaintID;
    }

    public Integer getComplaintID() {
        return complaintID;
    }

    public void setComplaintID(Integer complaintID) {
        this.complaintID = complaintID;
    }

    public String getComplaintNo() {
        return complaintNo;
    }

    public void setComplaintNo(String complaintNo) {
        this.complaintNo = complaintNo;
    }

    public Date getActualTime() {
        return actualTime;
    }

    public void setActualTime(Date actualTime) {
        this.actualTime = actualTime;
    }

    public Date getDateLodge() {
        return dateLodge;
    }

    public void setDateLodge(Date dateLodge) {
        this.dateLodge = dateLodge;
    }

    public Date getDateClose() {
        return dateClose;
    }

    public void setDateClose(Date dateClose) {
        this.dateClose = dateClose;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public Integer getSendTimes() {
        return sendTimes;
    }

    public void setSendTimes(Integer sendTimes) {
        this.sendTimes = sendTimes;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Status getStatus() {
        return status;
    }

    public void setStatus(Status status) {
        this.status = status;
    }

    public Priority getPriorityID() {
        return priorityID;
    }

    public void setPriorityID(Priority priorityID) {
        this.priorityID = priorityID;
    }

    public Category getCategoryID() {
        return categoryID;
    }

    public void setCategoryID(Category categoryID) {
        this.categoryID = categoryID;
    }

    public Account getAccountID() {
        return accountID;
    }

    public void setAccountID(Account accountID) {
        this.accountID = accountID;
    }

    public Account getTechnicianID() {
        return technicianID;
    }

    public void setTechnicianID(Account technicianID) {
        this.technicianID = technicianID;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (complaintID != null ? complaintID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Complaint)) {
            return false;
        }
        Complaint other = (Complaint) object;
        if ((this.complaintID == null && other.complaintID != null) || (this.complaintID != null && !this.complaintID.equals(other.complaintID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.spakehelpdesk.entity.Complaint[ complaintID=" + complaintID + " ]";
    }
    
}
